package cn.itsource.hbc.pay.service.impl;

import cn.itsource.basic.service.impl.BaseServiceImpl;
import cn.itsource.hbc.pay.contants.PayContants;
import cn.itsource.hbc.pay.domain.AliPayInfo;
import cn.itsource.hbc.pay.domain.PayBill;
import cn.itsource.hbc.pay.mapper.AliPayInfoMapper;
import cn.itsource.hbc.pay.mapper.PayBillMapper;
import cn.itsource.hbc.pay.service.IPayBillService;
import cn.itsource.hbc.pay.utils.AlipayUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class PayBillServiceImpl extends BaseServiceImpl<PayBill> implements IPayBillService {

    @Autowired
    private AliPayInfoMapper aliPayInfoMapper;
    @Autowired
    private PayBillMapper payBillMapper;

    @Override
    public String pay(PayBill payBill) {

        switch (payBill.getPayChannel()){

            case PayContants.ALIPAY:
                // 获取数据库数据
                AliPayInfo aliPayInfo = aliPayInfoMapper.loadById(1L);
                // 返回的信息html
                String result = AlipayUtils.alipay(payBill, aliPayInfo);
                return result;


            case PayContants.WXPAY:
                return "";

            case PayContants.UNIONPAY:
                 break;





        }










        return null;

    }

    @Override
    public PayBill queryByOrderSn(String orderSn) {
        return payBillMapper.queryByOrderSn(orderSn);
    }
}
